package com.demo.service.impl;

import com.demo.dto.OrderDTO;
import com.demo.entity.Carousel;
import com.demo.entity.Order;
import com.demo.mapper.CarouselMapper;
import com.demo.mapper.OrderMapper;
import com.demo.service.CarouselService;
import com.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper mapper;


    @Override
    public List<OrderDTO> findAllOrders() {
        List<OrderDTO> list = mapper.findAllOrders();
        list.forEach(item->{
            item.setSumPrice(mapper.findSumPriceByOrderId(item.getOrderId()));
        });
        return list;
    }

    @Override
    public List<Order> findOrdersById(BigDecimal orderId) {
        return mapper.findOrdersById(orderId);
    }


}
